-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visualize images from the batch #2063
base: main
Are you sure you want to change the base?
Visualize images from the batch #2063
Conversation
c2420fc
to
d76a5d1
Compare
Signed-off-by: Weilin Xu <weilin.xu@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visualizing images from the batch is a useful feature, but we might have to consider the original normalization transforms that are specific to the model or passed to the model.
height, width = batch["image"].shape[-2:] | ||
image = (read_image(path=batch["image_path"][i]) * 255).astype(np.uint8) | ||
image = cv2.resize(image, dsize=(width, height), interpolation=cv2.INTER_AREA) | ||
image = batch["image"][i].cpu().numpy().transpose(1, 2, 0) # HWC, RGB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is the best approach. I would recommend creating a new visualizer sub-classed from
class BaseVisualizer(ABC): |
outputs = kwargs.get("outputs", None) |
We are planning on refactoring the visualization callback so that we can pass the visualizers to the engine rather than hard-coding it but for now you can add the new visualizer to the list here
anomalib/src/anomalib/engine/engine.py
Line 437 in 56843d2
visualizers=ImageVisualizer(task=self.task, normalize=self.normalization == NormalizationMethod.NONE), |
Another option is to invert the normalization transforms attached to the model
Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), |
📝 Description
✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.